var vm = new Vue({
    el: '#rrapp',
    data() {
        return {
            showList: true,
            remittanceEntity:{}
        }
    },
    mounted() {
        this.getInfo()
    },
    methods: {
        saveOrUpdate: function () {
           if (!vm.remittanceEntity.receiverName) {
               alert('开户名不能为空')
               return
           }
           if (!vm.remittanceEntity.receiverAccount||!(/^[0-9]*$/.test(vm.remittanceEntity.receiverAccount))) {
               alert('银行账号格式不正确')
               return
           }
           if (!vm.remittanceEntity.receiverAccountBranch) {
               alert('开户银行不能为空')
               return
           }
           var self = this
            $.ajax({
                type: "POST",
                url: baseURL + "storeMember/storemember/bindBankCard",
                contentType: "application/json",
                data: JSON.stringify(vm.remittanceEntity),
                success: function (r) {
                    if (r.code === 0) {
                        vm.getInfo()
                        self.$alert('操作成功!点击确定返回主页', '提示信息', {
                            confirmButtonText: '确定',
                            callback: action => {
                                window.parent.vm.zyRouter({
                                    url:'main.html',
                                    name:'主页',
                                    blank: true,
                                    closeBlank: true,
                                    // vmName:'twbGoodsListVue',
                                    // params:{refresh:true},
                                });
                            }
                        });

                    } else {
                        alert(r.msg);
                    }
                }
            });
        },
        getInfo:function () {
            $.get(baseURL + "storeMember/storemember/bankCard", function (r) {
                if (r.code === 0) {
                    if (!r.remittanceEntity) {
                      vm.clearAll()
                    }else {
                        vm.remittanceEntity = r.remittanceEntity;
                    }
                }
            });
        },
        clearAll:function () {
            Vue.set(vm.remittanceEntity,'receiverName','')
            Vue.set(vm.remittanceEntity,'receiverCredential','')
            Vue.set(vm.remittanceEntity,'receiverAccount','')
            Vue.set(vm.remittanceEntity,'receiverAccountBranch','')
        }
    }
});